package com.boot.springBoot.juc;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

import lombok.extern.slf4j.Slf4j;
@Slf4j
public class FutureTest {
	
	static class TestFuture implements Callable<String>{

		@Override
		public String call() throws Exception {
			log.info("do something ..........");
			for (int i = 0; i < 10; i++) {
				log.info("我看看有几个线程执行----------"+i);
			}
			Thread.sleep(1000);
			for (int i = 10; i < 20; i++) {
				log.info("我看看有几个线程执行----------"+i);
			}
			return "Succ";
		}
		
	}
	
	public static void main(String[] args) throws InterruptedException, ExecutionException {



		ExecutorService task = Executors.newFixedThreadPool(5);
		Future<String> future = task.submit(new TestFuture());
		Future<String> future1 = task.submit(new TestFuture());
		log.info("future=={},当前线程：{}",future.get(),Thread.currentThread().getName());
		log.info("future=={},当前线程：{}",future1.get(),Thread.currentThread().getName());
		String a = "x"+"y";
		String b = "xy";
		String c = new String("xy");
		// 把c 放入常量池
		String d = c.intern();
		log.info("执行结果 == {}", a==b);
		log.info("执行结果 == {}", a==c);
		log.info("执行结果 == {}", a==d);
	}
}
